package borge.web.teamspirit.client.page.team.widgets;

import java.io.Serializable;
import java.util.List;

import borge.web.teamspirit.client.interfaces.DataProvider;
import borge.web.teamspirit.client.interfaces.WidgetEventHandler;
import borge.web.teamspirit.client.servercomm.DBQuery;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
import com.google.gwt.user.client.ui.SuggestBox;
import com.google.gwt.user.client.ui.SuggestOracle;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.SuggestOracle.Suggestion;

public class SearchDataWidget<T extends Serializable> extends BaseWidget implements ClickHandler, DataProvider, SelectionHandler<SuggestOracle.Suggestion>{

	protected SuggestBox iSuggestBox;
	protected ListBox iListBox;
	protected Button iSearchButton;
	
	protected FlexTable iTable;
	protected VerticalPanel iPanel;
	
	protected DBQuery<T> iQuery;
	
	public SearchDataWidget(WidgetEventHandler aWeh, List<String> aListItems, List<String> aSuggestItems){
		super(aWeh);
		
		MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
		for(String item : aSuggestItems)
			oracle.add(item);
		
		iSuggestBox = new SuggestBox(oracle);
		iSuggestBox.addSelectionHandler(this);
		iListBox = new ListBox();
		iSearchButton = new Button();
		iTable = new FlexTable();
		iPanel = new VerticalPanel();
		
		iSearchButton.setText("Search");
		iSearchButton.addClickHandler(this);
		
		for(String item : aListItems)
			iListBox.addItem(item);
	}

	@Override
	public void onClick(ClickEvent event) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public DBQuery<T> getDataObject() {
		// TODO Auto-generated method stub
		return iQuery;
	}


	@Override
	public void onSelection(SelectionEvent<Suggestion> event) {
		// TODO Auto-generated method stub
		
	}
	
	
	
}
